<?php
class SQLImport {
	function splitQueryText($file) {
		$query = file_get_contents($file);
	    // the regex needs a trailing semicolon
	    $query = trim($query);
	
	    if (substr($query, -1) != ";")
	        $query .= ";";
	
	    // i spent 3 days figuring out this line
	    preg_match_all("/(?>[^;']|(''|(?>'([^']|\\')*[^\\\]')))+;/ixU", $query, $matches, PREG_SET_ORDER);
	
	    $querySplit = "";
	
	    foreach ($matches as $match) {
	        // get rid of the trailing semicolon
	        $querySplit[] = substr($match[0], 0, -1);
	    }
	
	    return $querySplit;
	}
	
}
?>